Skip to content

fleet-secrets: bound every fallback subprocess wait (#14040 Residual B) - #14362

Merged
dezren39 merged 1 commit into
mainfrom
queue/23285-neverhang-b
Nov 24, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/23285-neverhang-b

Conversation

@dezren39

@dezren39 dezren39 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Refs #14040 (Residual B only — the issue stays open for Residual A), #13948. Queue task 23285.

What

Every subprocess wait in the secrets client's fallback chain is now bounded. The bws and op tiers spawned children through Command::output(), which waits forever — a wedged child was the one remaining path by which a secrets client could still hang under the never-hang ruling (#14040 Residual B). The broker legs got their per-attempt bound in PR #14021; the subprocess waits never did.

  • run_command_bounded — a bounded Command::output(): spawn, drain stdout/stderr on threads (a chatty child cannot deadlock the wait on a full pipe), poll try_wait, kill at the deadline. Same spawn/poll/kill shape as the secrets broker's own BwsRunner in fleet-queue.
  • SUBPROCESS_ATTEMPT_TIMEOUT = 10s — one named per-invocation ceiling mirroring BROKER_ATTEMPT_TIMEOUT, carried by ProcessRunner (the op tier) and BwsTokenRunner (the bws tier). Both runners accept a caller-chosen ceiling so tests can prove the bound without waiting out the production one.
  • The bws --version probe is bounded too (PROGRAM_PROBE_TIMEOUT = 5s, via program_runs_within): a wedged candidate now fails the runnable gate in resolve_bws_program instead of hanging program resolution.

Tests

cargo test -p fleet-secrets — 42 passed, 0 failed, including 5 new tests that drive a real never-exiting child (sh -c "sleep 60") through the helper, both runners, and the probe, asserting the timed out error lands well inside the bound; a quick-child test pins output/status behaviour. cargo check -p fleet-queue and cargo check -p fleet pass (the CommandRunner trait itself is unchanged, so the broker's BwsRunner impl is untouched).

Test route note: a fleet Actions exec session was attempted first — the detached dispatch returned HTTP 422 and an earlier attached start timed out at the channel — so the suite ran with cargo in the laptop worktree (not a nix-store build), the same fallback ITEM-WORK-134 used. Repo CI runs on main only, so it verifies this change on the merge push. cargo clippy could not run on the laptop: its rustc (1.99.1) rejects the prebuilt registry artifacts of unrelated dependency crates with E0514 — a host toolchain mismatch, pre-existing and untouched by this diff.

Out of scope (per the packet)

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-24T13:29:07Z",
    "session_id": null,
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/wt-lane-23285-neverhang",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/wt-lane-23285-neverhang",
      "repo": "developing-today/code",
      "branch": "queue/23285-neverhang-b",
      "sha": "2c0f7e04269140006c7f19a4eecbd18adb434781"
    },
    "auth_subject": "oc-code-08",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The secrets client's fallback tiers spawned `bws` / `op` children
through Command::output(), which waits forever -- a wedged child
was the one remaining path by which a client could still hang
under the never-hang ruling. The broker legs already bound each
exchange (BROKER_ATTEMPT_TIMEOUT, PR #14021); the subprocess
waits did not.

- run_command_bounded: a bounded Command::output() -- spawn,
  drain stdout/stderr on threads, poll try_wait, kill at the
  deadline. Same spawn/poll/kill shape as the secrets broker's
  own BwsRunner in fleet-queue.
- SUBPROCESS_ATTEMPT_TIMEOUT (10s, mirroring
  BROKER_ATTEMPT_TIMEOUT) is the per-invocation ceiling carried
  by ProcessRunner (the `op` tier) and BwsTokenRunner (the `bws`
  tier); both runners take a caller-chosen ceiling for tests.
- The `bws --version` probe in program resolution is bounded too
  (PROGRAM_PROBE_TIMEOUT, 5s): a wedged candidate now fails the
  runnable gate instead of hanging resolution.
- Tests drive a real never-exiting child (sh -c "sleep 60")
  through the helper, both runners, and the probe, asserting the
  timeout error lands well inside the bound; a quick-child test
  pins output/status behaviour.

Out of scope per the packet: BROKER_RETRY_BUDGET /
BROKER_ATTEMPT_TIMEOUT unchanged (Residual A stays decided
separately on #14040). The broker server's own refresh runner
(fleet-queue BwsRunner) already bounds its child at 60s and is
not part of the client fallback chain.

Refs #14040, #13948. Queue task 23285.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4012828b-9daa-4cf1-8589-e1c422c3f23e
Commits

Reviewing files that changed from the base of the PR and between d5a4a04 and 2c0f7e0.

Files selected for processing: 1

  • pkgs/fleet/crates/fleet-secrets/src/lib.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39
dezren39 merged commit 3b7ba82 into main Nov 24, 2026
2 checks passed
@dezren39
dezren39 deleted the queue/23285-neverhang-b branch November 24, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant